package com.example.demo.common;

import com.alibaba.fastjson.JSONObject;
import com.amazonaws.services.lambda.model.SourceAccessConfiguration;
import com.example.demo.common.com.example.demo.Test;

import java.text.NumberFormat;
import java.util.*;

/**
 * 常规
 *
 * @author ldl
 */
public class TestController {

    private final Integer t = 1;

    public static void main(String[] args) {


        System.out.println(50000 * 0.032 / 3);

        System.out.println(50000 * 0.035);

        System.out.println(50000 * 0.036);

        System.out.println(50000 * 0.039 + 50000 * 0.035);

        Boolean hasNext = true;
        int wrongNum = 0; // 失败页次数
        int wrongMaxNum = 5; // 失败页最多尝试次数
        boolean hasWrong = false;
        while (hasNext) {

            // 最多尝试wrongMaxNum个失败页，则退出列表查询
            if (true) {

                hasWrong = true;
                wrongNum++;
                if (wrongNum >= wrongMaxNum) {

                    break;
                }


                hasNext = true;
                continue;
            } else {
                //成功请求以后,将错误次数置为零

                wrongNum = 0;
            }


        }


        List<String> s = new ArrayList<>();
        s.add("1");
        s.add("2");
        for (int i = 0; i < s.size(); i++) {
            s.set(i, "a");
        }
        System.out.println(JSONObject.toJSONString(s));

        String[] pic = new String[5];
        pic[1] = "11";
        pic[1] = "11";
        pic[1] = "11";

        System.out.println(JSONObject.toJSONString(pic));

        int diliverNum = 3;//举例子的变量

        int queryMailNum = 9;//举例子的变量

// 创建一个数值格式化对象

        NumberFormat numberFormat = NumberFormat.getInstance();

// 设置精确到小数点后2位

        numberFormat.setMaximumFractionDigits(0);

        String result = numberFormat.format((float) diliverNum / (float) queryMailNum * 100);

        System.out.println("diliverNum和queryMailNum的百分比为:" + result + "%");


        Test t = new Test(1, "11");

       /* Integer i = 10;
        Long l = i.longValue();

        long a = 10;
        int b = (int) a;

        int a1 = 10;
        long b1 = a1;

        int aa = 10;
        long bb = (long) aa;*/

        /*Integer obj = 11111;
        System.out.println(obj);*/


        /*Integer tt1 = new Integer(1);
        System.out.println((long) tt1); //等价于tt1.longValue()
        //System.out.println((Long) tt1); //error
        Object obj1 = "1";
        Object obj = new Integer(100);
        Object obj2 = new Long(76765);

        //System.out.println((Integer)obj2);//error

        System.out.println((Integer) obj);
        //System.out.println((String) obj);
        //System.out.println((Long) obj);
        System.out.println((Object) obj);

        System.out.println((Integer) obj1);//error
        //ystem.out.println((String) obj1);
        //System.out.println((Long) obj1);
        System.out.println((Object) obj1);*/


        Object o2 = new Long(2L);


        Object o1 = new Integer(1);


        Integer i1 = new Integer(1);


        System.out.println(o2 instanceof String);
        System.out.println(o1 instanceof Long);


    }
}
